package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;

import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;
import com.jrzh.framework.base.search.BaseSearch;

public class FileRuleSearch extends BaseSearch{
	private static final long serialVersionUID = 1L;

	private String likeName;
	private String inEqualFormId;
	private String eqKey;
	private Object[] inKey;

	private String[] inNames;

	public Object[] getInKey() {
		return inKey;
	}

	public void setInKey(Object[] inKey) {
		this.inKey = inKey;
	}

	public String getInEqualFormId() {
		return inEqualFormId;
	}

	public void setInEqualFormId(String inEqualFormId) {
		this.inEqualFormId = inEqualFormId;
	}

	public String getLikeName() {
		return likeName;
	}

	public void setLikeName(String likeName) {
		this.likeName = likeName;
	}


	public String[] getInNames() {
		return inNames;
	}

	public void setInNames(String[] inNames) {
		this.inNames = inNames;
	}

	public String getEqKey() {
		return eqKey;
	}

	public void setEqKey(String eqKey) {
		this.eqKey = eqKey;
	}

	@Override
	public void setCriterias(Criteria<?> criterias) {
		if(StringUtils.isNotBlank(likeName)){
			criterias.add(Restrictions.like("name", "%"+likeName+"%"));
		}
		if(null!=inNames && inNames.length > 0){
			criterias.add(Restrictions.in("name", inNames));
		}
		if(StringUtils.isNotBlank(inEqualFormId)){
			criterias.add(Restrictions.in("formId", inEqualFormId));
		}
		if(StringUtils.isNotBlank(eqKey)){
			criterias.add(Restrictions.eq("key", eqKey));
		}
		if(null != inKey && inKey.length>0 ){
			criterias.add(Restrictions.in("key" ,inKey));
		}
	}

}